package game.ui.controls
{
	import engine.asset.*;
	import flash.display.*;
	import flash.text.*;
	import game.localization.*;
	import game.ui.core.*;
	
	public class RxNumberDisplay extends RxUIElement
	{
		private var m_value:int = -1;
		private var m_textField:RxTextLabel;
		private var m_icon:Shape;
		private var m_background:Shape;
		private var m_buyButton:RxRoundButton;
		private var m_labelField:RxTextLabel;
		private var m_isCurrency:Boolean;
		
		public function RxNumberDisplay(param1:String, param2:Function, param3:Boolean = false)
		{
			m_width = 160;
			m_height = 30;
			this.m_background = new Shape();
			addChild(this.m_background);
			this.m_icon = new Shape();
			addChild(this.m_icon);
			this.m_textField = RxTextLabel.CreateWithStyle(RxFontStyleConstants.BODY_LARGE, 14208961, TextFormatAlign.RIGHT);
			addChild(this.m_textField);
			this.m_labelField = RxTextLabel.CreateWithStyle(RxFontStyleConstants.BODY_MEDIUM, 16777215, TextFormatAlign.RIGHT);
			addChild(this.m_labelField);
			this.m_buyButton = new RxRoundButton();
			this.m_buyButton.SetIconUrl("ui/icons/icon_plus.png");
			this.m_buyButton.width = 27;
			this.m_buyButton.height = 25;
			this.m_buyButton.SetCallback(param2);
			addChild(this.m_buyButton);
			this.m_isCurrency = param3;
			var _loc_4:* = new RxAssetGroup();
			new RxAssetGroup().AddCallback(new RxAssetCallback(this.OnAssetsLoaded));
			_loc_4.AddAsset(RxAssetImage.Create("ui/hud/counters/counter_bg.png", null));
			if (param1 != null)
			{
				_loc_4.AddAsset(RxAssetImage.Create(param1, null));
			}
			_loc_4.Load();
		}
		
		private function OnAssetsLoaded(param1:RxAssetCallback) : void
		{
			var _loc_2:RxAssetGroup = null;
			var _loc_3:RxAssetImage = null;
			var _loc_4:BitmapData = null;
			if (param1.m_result == true)
			{
				_loc_2 = param1.m_asset as RxAssetGroup;
				_loc_3 = _loc_2.GetAsset(0) as RxAssetImage;
				_loc_4 = _loc_3.GetBitmapData();
				this.m_background.graphics.beginBitmapFill(_loc_4);
				this.m_background.graphics.drawRect(0, 0, _loc_4.width, _loc_4.height);
				this.m_background.graphics.endFill();
				_loc_3 = _loc_2.GetAsset(1) as RxAssetImage;
				if (_loc_3 != null)
				{
					_loc_4 = _loc_3.GetBitmapData();
					this.m_icon.graphics.beginBitmapFill(_loc_4);
					this.m_icon.graphics.drawRect(0, 0, _loc_4.width, _loc_4.height);
					this.m_icon.graphics.endFill();
				}
				InvalidateSize();
				DispatchInitialized();
			}
		}
	}
}